package com.example.e.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.e.mapper.LoginMapper;
import com.example.e.enity.Login;
import com.example.feign.feign.BServiceFeign;
import com.example.feign.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author: YangHaoZhong
 * @time: 2023/12/29
 */
@RestController
@RequestMapping("/e")
public class FeiginController {
    @Autowired
    public BServiceFeign bService;

    @Autowired
    private LoginMapper loginMapper;
    @PostMapping("/selectE")
    public Result aQQ2() {
        Result result = bService.aQQ3();
        Object data = result.getData();
        String jsonString = JSON.toJSONString(data);
//        Login login = JSON.parseObject(data.toString(), Login.class);
        List<Login> logins = JSONObject.parseArray(jsonString, Login.class);
        String name = logins.get(0).getName();
        System.out.println(name);
        System.out.println(logins.get(0).getPassword());

        logins.forEach(System.out::println);
        return Result.success(data);
    }

    @PostMapping("/selectE2")
    public Result aQQ3() {

        List<Login> logins = loginMapper.selectList(new LambdaQueryWrapper<>());


        return Result.success(logins);
    }
}
